package ar.republicagroup.gestion.view;

import ar.republicagroup.gestion.entities.Caja;
import ar.republicagroup.gestion.entities.MovimientoTipo;
import ar.republicagroup.gestion.services.CajaServices;
import ar.republicagroup.gestion.services.ClienteServices;
import ar.republicagroup.gestion.services.CuentaBancoServices;
import ar.republicagroup.gestion.services.MovimientoTipoServices;
import ar.republicagroup.gestion.util.JComboBoxModel;
import ar.republicagroup.gestion.util.SpringUtils;
import ar.republicagroup.gestion.util.UserSession;
import ar.republicagroup.gestion.util.Validar;
import ar.republicagroup.gestion.util.helpers.Formato;
import ar.republicagroup.gestion.util.helpers.UserInterfaceHelper;
import ar.republicagroup.gestion.util.messages.UIMessages;
import ar.republicagroup.gestion.factory.MovimientoCaja;
import ar.republicagroup.gestion.factory.MovimientoCajaFactory;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

public class FrmAddMovimiento extends javax.swing.JFrame {

   CuentaBancoServices  cuentaBancoServices         = (CuentaBancoServices)SpringUtils.getBean("cuentaBancoServices");
   ClienteServices      clienteServices             = (ClienteServices)SpringUtils.getBean("clienteServices");
   MovimientoTipoServices movimientoTipoServices    = (MovimientoTipoServices)SpringUtils.getBean("movimientoTipoServices");
   CajaServices cajaServices                         = (CajaServices)SpringUtils.getBean("cajaServices");
   private static FrmAddMovimiento instance;
   
   private List<Caja> movimientos = new ArrayList<>() ;
   
   public static FrmAddMovimiento getInstance(){
       
       if(instance == null){
           instance =  new FrmAddMovimiento();
       }
       
       return instance;
   }
   
    private FrmAddMovimiento() {
        initComponents();
        cargarDatos();
        valoresPorDefecto();
    }
    
    private void cargarDatos(){
        comboClienteCuenta.setModel(cuentaBancoServices.combo());
    }
    
    private void valoresPorDefecto(){
        this.setIconImage(new ImageIcon(getClass().getResource("/ar/republicagroup/gestion/view/images/moneybox.png")).getImage());
        UserInterfaceHelper.setTitleToThisJFrame(this, "Nuevo movimiento en caja");
        rbtRetiro.setSelected(true);
        lblConcepto.setVisible(Boolean.FALSE);
        txtConcepto.setVisible(Boolean.FALSE);        
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jCheckBox1 = new javax.swing.JCheckBox();
        buttonGroupTipoMov = new javax.swing.ButtonGroup();
        jPopupMenu1 = new javax.swing.JPopupMenu();
        menuItemEdit = new javax.swing.JMenuItem();
        menuItemDelete = new javax.swing.JMenuItem();
        pnlDatosMov = new javax.swing.JPanel();
        comboClienteCuenta = new javax.swing.JComboBox();
        lblTipoMov = new javax.swing.JLabel();
        txtImporte = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        lblConcepto = new javax.swing.JLabel();
        txtConcepto = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblMovimientos = new javax.swing.JTable();
        btnConfirmar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        rbtRetiro = new javax.swing.JRadioButton();
        rbtPagos = new javax.swing.JRadioButton();
        rbtGastosDiarios = new javax.swing.JRadioButton();
        rbtGastosBanco = new javax.swing.JRadioButton();
        txtTotal = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        jCheckBox1.setText("jCheckBox1");

        menuItemEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ar/republicagroup/gestion/view/images/edit.png"))); // NOI18N
        menuItemEdit.setText("Modificar");
        menuItemEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemEditActionPerformed(evt);
            }
        });
        jPopupMenu1.add(menuItemEdit);

        menuItemDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ar/republicagroup/gestion/view/images/delete.png"))); // NOI18N
        menuItemDelete.setText("Eliminar");
        menuItemDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemDeleteActionPerformed(evt);
            }
        });
        jPopupMenu1.add(menuItemDelete);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        pnlDatosMov.setBorder(javax.swing.BorderFactory.createTitledBorder("Ingrese datos del movimiento"));

        lblTipoMov.setText("Cuenta:");

        txtImporte.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtImporteKeyPressed(evt);
            }
        });

        jLabel2.setText("Importe:");

        lblConcepto.setText("Concepto:");

        javax.swing.GroupLayout pnlDatosMovLayout = new javax.swing.GroupLayout(pnlDatosMov);
        pnlDatosMov.setLayout(pnlDatosMovLayout);
        pnlDatosMovLayout.setHorizontalGroup(
            pnlDatosMovLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosMovLayout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(pnlDatosMovLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblConcepto)
                    .addComponent(jLabel2)
                    .addComponent(lblTipoMov))
                .addGap(18, 18, 18)
                .addGroup(pnlDatosMovLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(comboClienteCuenta, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtImporte, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtConcepto, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlDatosMovLayout.setVerticalGroup(
            pnlDatosMovLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosMovLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(pnlDatosMovLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboClienteCuenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblTipoMov))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDatosMovLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtImporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDatosMovLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtConcepto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblConcepto))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        tblMovimientos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Movimiento", "Concepto", "Importe"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblMovimientos.setComponentPopupMenu(jPopupMenu1);
        jScrollPane2.setViewportView(tblMovimientos);

        btnConfirmar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ar/republicagroup/gestion/view/images/check.png"))); // NOI18N
        btnConfirmar.setText("Confirmar");
        btnConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConfirmarActionPerformed(evt);
            }
        });

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ar/republicagroup/gestion/view/images/cancel.png"))); // NOI18N
        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Seleccione el tipo de movimiento"));

        buttonGroupTipoMov.add(rbtRetiro);
        rbtRetiro.setText("Retiro");
        rbtRetiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtRetiroActionPerformed(evt);
            }
        });

        buttonGroupTipoMov.add(rbtPagos);
        rbtPagos.setText("Pagos");
        rbtPagos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtPagosActionPerformed(evt);
            }
        });

        buttonGroupTipoMov.add(rbtGastosDiarios);
        rbtGastosDiarios.setText("Gastos diarios");
        rbtGastosDiarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtGastosDiariosActionPerformed(evt);
            }
        });

        buttonGroupTipoMov.add(rbtGastosBanco);
        rbtGastosBanco.setText("Gastos bancos");
        rbtGastosBanco.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtGastosBancoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addComponent(rbtRetiro)
                .addGap(18, 18, 18)
                .addComponent(rbtPagos)
                .addGap(18, 18, Short.MAX_VALUE)
                .addComponent(rbtGastosDiarios)
                .addGap(18, 18, 18)
                .addComponent(rbtGastosBanco)
                .addGap(15, 15, 15))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rbtRetiro)
                    .addComponent(rbtPagos)
                    .addComponent(rbtGastosDiarios)
                    .addComponent(rbtGastosBanco))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        txtTotal.setEditable(false);

        jLabel1.setText("Total");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnConfirmar)
                        .addGap(18, 18, 18)
                        .addComponent(btnCancelar)
                        .addGap(37, 37, 37)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtTotal))
                    .addComponent(pnlDatosMov, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlDatosMov, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnConfirmar)
                    .addComponent(btnCancelar)
                    .addComponent(jLabel1))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void rbtRetiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtRetiroActionPerformed
        if(rbtRetiro.isSelected()){
            lblTipoMov.setVisible(true);
            mostrarCombo("Cuenta", cuentaBancoServices.combo());
            txtConcepto.setVisible(false);
            lblConcepto.setVisible(false);
        }
    }//GEN-LAST:event_rbtRetiroActionPerformed

    private void rbtPagosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtPagosActionPerformed
        if(rbtPagos.isSelected()){
            lblTipoMov.setVisible(true);
            mostrarCombo("Cliente", clienteServices.combo());
            txtConcepto.setVisible(false);
            lblConcepto.setVisible(false);
        }
    }//GEN-LAST:event_rbtPagosActionPerformed

    private void rbtGastosBancoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtGastosBancoActionPerformed
       if(rbtGastosBanco.isSelected()){
           mostrarCombo("Cuenta", cuentaBancoServices.combo());
           txtConcepto.setVisible(false);
           lblConcepto.setVisible(false);
           lblTipoMov.setVisible(true);
       }
    }//GEN-LAST:event_rbtGastosBancoActionPerformed

    private void rbtGastosDiariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtGastosDiariosActionPerformed
        if(rbtGastosDiarios.isSelected()){
            lblTipoMov.setVisible(false);
            comboClienteCuenta.setVisible(false);
            txtConcepto.setVisible(true);
            lblConcepto.setVisible(true);
        }
    }//GEN-LAST:event_rbtGastosDiariosActionPerformed

    private void txtImporteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtImporteKeyPressed

        if(evt.getKeyCode() == KeyEvent.VK_ENTER){
            String importeString = txtImporte.getText();
            if(! Validar.esVacio(importeString) ){
                if(Validar.esUnDatoDouble(importeString)){
                    double importe = Double.parseDouble(importeString);
                    agregarMovimiento(importe);
                    txtImporte.setText("");
                }else{
                    JOptionPane.showMessageDialog(this, UIMessages.getErrorMessage("decimal"),UIMessages.getErrorMessage("defaultErrorTitle") , JOptionPane.ERROR_MESSAGE);
                    txtImporte.requestFocus();
                    txtImporte.selectAll();
                }
            } else{
                JOptionPane.showMessageDialog(this,  UIMessages.getErrorMessage("decimal"),UIMessages.getErrorMessage("defaultErrorTitle"), JOptionPane.ERROR_MESSAGE);
                txtImporte.requestFocus();
                txtImporte.selectAll();
            }
        }      
    }//GEN-LAST:event_txtImporteKeyPressed

    private void btnConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfirmarActionPerformed
        if(! movimientos.isEmpty() ){
            for(Caja movimiento : movimientos){
                cajaServices.insert(movimiento);
            }
        }
   
    }//GEN-LAST:event_btnConfirmarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        dispose();
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void menuItemEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemEditActionPerformed
        System.out.println("Hello World!");
    }//GEN-LAST:event_menuItemEditActionPerformed

    private void menuItemDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemDeleteActionPerformed
        int[] rowsDeleted = tblMovimientos.getSelectedRows();
        DefaultTableModel model = (DefaultTableModel)tblMovimientos.getModel();
        List<Caja> movimientosToDelete = new ArrayList<>();
        
        for (int i = rowsDeleted.length - 1; i >= 0; i--) {
                 model.removeRow(rowsDeleted[i]);
                 movimientos.remove(i);
        }
        
        actualizarTotalImporte();

    }//GEN-LAST:event_menuItemDeleteActionPerformed

    private void actualizarTotalImporte(){
        double totalImporte = 0;
        
        if (!movimientos.isEmpty()){
            for(Caja caja : movimientos){
                totalImporte += caja.getImporte().doubleValue();
                System.out.println(totalImporte);
            }
        }
        
        txtTotal.setText(Formato.decimalComaMilesConSigno(totalImporte));
        
    }
    
    private void agregarMovimiento(double importe){
        
        JComboBoxModel comboModel       = (JComboBoxModel)comboClienteCuenta.getSelectedItem();
        String selectedRetiro           = UserInterfaceHelper.getSelectedButtonText(buttonGroupTipoMov);
        MovimientoTipo movimientoTipo   = movimientoTipoServices.getMovimientoTipoByName(selectedRetiro);
        String tipoMov                  = movimientoTipo.getNombre();
        
        /* Creamos un map con los params para el nuevo movimiento*/
        Map<String,Object> params   = crearMapParamsMov(importe,movimientoTipo);
        /* Obtenemos el tipo de movimiento del Factory y creamos el movimiento */
        MovimientoCaja movCaja      = MovimientoCajaFactory.getMovimientoCaja(tipoMov);
        Caja caja                   = movCaja.createMovimiento(params);
        
        DefaultTableModel model = (DefaultTableModel)tblMovimientos.getModel();
        model.addRow(new Object[]{tipoMov , caja.getDescripcion(), Formato.decimalComaMilesConSigno( caja.getImporte().doubleValue() ) });
        movimientos.add(caja);
        actualizarTotalImporte();
        
    }
    
    
    private Map<String,Object> crearMapParamsMov(double importe,MovimientoTipo movimiento){
        Map<String,Object> params = new HashMap<>();
        params.put("importe",importe);
        params.put("combo", comboClienteCuenta.getSelectedItem());
        params.put("usuarioId",UserSession.getInstance().getUser_id());
        params.put("movimiento",movimiento);
        if( txtConcepto.isVisible() ){
            params.put("concepto", txtConcepto.getText());
        }
        
        return params;
    }
    
    
    private void mostrarCombo(String labelText,DefaultComboBoxModel model){
        comboClienteCuenta.setVisible(true);
        lblTipoMov.setText(labelText);
        comboClienteCuenta.setModel(model);
    }
    
    
   
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmAddMovimiento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmAddMovimiento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmAddMovimiento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmAddMovimiento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrmAddMovimiento().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnConfirmar;
    private javax.swing.ButtonGroup buttonGroupTipoMov;
    private javax.swing.JComboBox comboClienteCuenta;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel lblConcepto;
    private javax.swing.JLabel lblTipoMov;
    private javax.swing.JMenuItem menuItemDelete;
    private javax.swing.JMenuItem menuItemEdit;
    private javax.swing.JPanel pnlDatosMov;
    private javax.swing.JRadioButton rbtGastosBanco;
    private javax.swing.JRadioButton rbtGastosDiarios;
    private javax.swing.JRadioButton rbtPagos;
    private javax.swing.JRadioButton rbtRetiro;
    private javax.swing.JTable tblMovimientos;
    private javax.swing.JTextField txtConcepto;
    private javax.swing.JTextField txtImporte;
    private javax.swing.JTextField txtTotal;
    // End of variables declaration//GEN-END:variables
}
